package com.bds.btcdc.web.service;

import com.bds.btcdc.web.model.StrategyManyArgs;
import org.apache.log4j.Logger;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by DongChenchen on 2018/5/7 0007
 */
@Service
public class CoinService {
    private Logger LOGGER = Logger.getLogger(getClass());
    @Resource
    private NutDao dao;

    public List getAllUsing(){
        Sql sql = Sqls.create("Select a.en_coin_name from t_coin_name a");
        sql.setCallback(new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                List<String> list = new LinkedList<String>();
                while (rs.next())
                    list.add(rs.getString(1));
                return list;
            }
        });
        dao.execute(sql);
        return sql.getList(String.class);
    }

    public void test(){
        dao.create(StrategyManyArgs.class,false);
    }

}
